home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / procssng / ccs / ccs-11.lha / ccs-lib / include / panel.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-08-16  |  10.8 KB  |  414 lines

  1. /*    PANEL . H
  2. %
  3. %    Panel Protocols
  4. %
  5. %    Copyright (c)    1991, 1993    Jin Guojun
  6. %
  7. % AUTHOR:    Jin Guojun - Lawrence Berkeley Laboratory    2/1/91
  8. */
  9.  
  10. #ifndef    PANEL_H
  11. #define    PANEL_H
  12.  
  13. #include <X11/Xlib.h>
  14. #include <X11/Xutil.h>
  15. #include <X11/cursorfont.h>
  16. #include <X11/keysym.h>
  17. #include "stdef.h"
  18.  
  19. #ifndef    MType
  20. #ifdef    TC_Need    /* for different Machine Memory allocating    */
  21. #    define    MType    long
  22. #else
  23. #    define    MType    int
  24. #endif
  25. #endif    MType
  26.  
  27. #ifndef MAX
  28. # define MAX(A,B)    ((A > B) ? A : B)
  29. #endif
  30. #ifndef MIN
  31. # define MIN(A,B)    ((A < B) ? A : B)
  32. #endif
  33. #ifndef ABS
  34. # define ABS(A)        ((A < 0) ? -(A) : A)
  35. #endif
  36. #ifndef    Sign
  37. #define    Sign(v)        ((v < 0) ? -1 : v!=0)
  38. #endif
  39.  
  40. typedef    longword    PColor;
  41.  
  42. /* for passing message, it can be used for different purpose */
  43.  
  44. typedef    struct    {
  45.     int    min, max,
  46.         maxcnt;
  47.     } Mregister;
  48.  
  49. typedef    struct    {
  50.     int    screen, dpy_depth;
  51.     Visual    *visual;
  52.     Colormap cmap;
  53.     Display    *dpy;
  54.     bool    Mask, reserved;
  55.     Window    root;
  56.     } WinAttribute;
  57.  
  58. extern    WinAttribute    Monitor[2];
  59. #define    Dpy        Monitor[0].dpy
  60. #define    Screen        Monitor[0].screen
  61. #define    Root_window    Monitor[0].root
  62.  
  63.  
  64. typedef    struct    {
  65.     char    *name, *history, *desc;
  66.     Colormap colormap;
  67.     Display    *dpy;
  68.     GC    gc, igc;
  69.     Window    frame, win, icon;
  70.     XEvent    *event;
  71.     int    x0, y0, width, height,
  72.         icon_width, icon_height,
  73.         font_w, font_h, ascent;
  74.     } AnyWindow;
  75.  
  76.  
  77. #ifndef    xview_panel_DEFINED    /* used in xview guide    */
  78.  
  79. typedef    struct    {
  80.     char    *name, *history, *desc;
  81.     Colormap    colormap;
  82.     Display        *dpy;
  83.     GC        gc, igc;
  84.     Window        frame, win, icon;
  85.     XExposeEvent    *expose;
  86.     int        x0, y0, width, height,
  87.             icon_width, icon_height,
  88.             font_w, font_h, ascent;
  89.     Window        root;
  90.     XEvent        event;
  91.     } Panel;
  92. #endif
  93.  
  94. typedef    struct    {
  95.     char    *name, *info, *desc;
  96.     long    reserved;
  97.     Panel    *pan;
  98.     bool    state, valid;
  99.     PColor    color, vcolor, tcolor;
  100.     VType    *ep;
  101.     int    x, y, w, h;
  102.     } AnyParts;
  103.  
  104. typedef    struct    {
  105.     char    *name, **bname, *desc;
  106.     long    reserved;
  107.     Panel    *pan;
  108.     bool    pressed, valid;
  109.     PColor    dimcolor, vcolor, tcolor;
  110.     VType    *ep;
  111.     int    x, y, rmb, hei;    /* right most bound    */
  112.     PColor    *color;
  113.     int    namex, *bw, numb;    /* button width & number */
  114.     } Button;
  115.  
  116. typedef    struct    {
  117.     char    *name, *nouse, *desc;
  118.     long    reserved;
  119.     Panel    *pan;
  120.     bool    state, valid;
  121.     union    {
  122.     PColor    s[2],
  123.         p, v;    /* pressed & regular visible colors */
  124.         }color;
  125.     PColor    tcolor;    /* title color */
  126.     VType    *ep;
  127.     int    x, y, len, hei;
  128.     } PressButton;
  129.  
  130. typedef    struct    {
  131.     char    *name, **menu, *desc;
  132.     long    reserved;
  133.     Display    *dpy;
  134.     GC    gc, igc;
  135.     Window    frame, win, icon;
  136.     VType*    interface;
  137.     int    x0, y0, w, h, items, which,
  138.         font_w, font_h, ascent;
  139.     PColor    bgcolor, fgcolor;
  140.     } PopMenu;
  141.  
  142. typedef    struct    {
  143.     char    *name, *info, *desc;
  144.     long    reserved;
  145.     Panel    *pan;
  146.     bool    vert, valid;
  147.     PColor    rcolor, vcolor, tcolor; /* regular, visible, title colors */
  148.     VType    *ep;
  149.     int    rx, ry, rw, rl;
  150.     PColor    *scolor;
  151.     int    *sx, *sy, sw, sh, numb,    /* scrollbar parameter */
  152.         scale, min, max,
  153.         defscale, defmin, defmax,/* default scale, min and max */
  154.         namex, infx, infy;
  155.     } Slider;
  156.  
  157. typedef    struct    {
  158.     char    *name, *vp, *desc;
  159.     long    reserved;
  160.     AnyWindow    *awin;
  161.     bool    hvalid, vvalid;
  162.     PColor    rcolor, vcolor, bcolor; /* regular, vert, bar colors.    */
  163.     VType    *ep;
  164.     int    *rx, *ry, *rw, *rl;
  165.     MType    type;    /* 0 horizontal, 1 vertical, or 2 both.    */
  166.     int    *bx, *by;
  167. #ifdef    SCROLLBAR_on_CANVAS
  168.     int    lx, ly;
  169.     Window    h_swin, v_swin;
  170. #endif
  171.     } ScrollBar;
  172.  
  173. typedef    union    {
  174.     Panel        pan;
  175.     AnyParts    aparts;
  176.     AnyWindow    awin;
  177.     Button        button;
  178.     PressButton    pbutton;
  179.     PopMenu        popmenu;
  180.     Slider        slider;
  181.     ScrollBar    scrollbar;
  182.     } PanelParts;
  183.  
  184. #define    RESETSTATE    0
  185. #define    ButtonState(button)    button->pressed
  186. #define    PressButtonState(pbutton)    pbutton->state
  187. #define    HidingPanel(pan)    XUnmapWindow(pan->dpy, pan->win)
  188. #define    HidingPopMenu(popmenu)    XUnmapWindow(popmenu->dpy, popmenu->win)
  189. #define    GetGray(dpy, cmap, entries, gray)    \
  190.     GetCloseColor(dpy, cmap, entries, NULL, gray, gray, gray)
  191.  
  192. #define    PopButtonMask    Button1
  193.  
  194. /*    Setting Codes For PANELSET()    */
  195. #define    BUTTON_COLOR        1
  196. #define    PRESS_BUTTON_COLOR    2
  197. #define    SLIDER_COLOR        3
  198. #define    PANEL_BACKGROUND    4
  199. #define    PANEL_ACCESSORies    5
  200.  
  201.  
  202. typedef    struct    {
  203.     char    *name, *history, *desc;
  204.     Colormap colormap;
  205.     Display    *dpy;
  206.     GC    gc, igc;
  207.     Window    frame, win, icon;
  208.     XEvent    *event;
  209.     int    x0, y0, width, height,
  210.         icon_width, icon_height,
  211.         font_w, font_h, ascent;
  212.     XImage    *image, *icon_image;
  213.     int    curve, linearlow, linearup, bgrd, fgrd,    /* elastic curve */
  214.         scale, tmp_offset,    /* this 2 fields used for anything */
  215.         mark_x, mark_y, resize_w, resize_h,
  216.         sub_img_x, sub_img_y, sub_img_w, sub_img_h,
  217.         mag_fact, mag_mode,    /* display magnified image    */
  218.         mag_x, mag_y, mag_w, mag_h,/* subimage currently being viewed */
  219.         save_mag_x, save_mag_y, save_mag_w, save_mag_h,
  220.         save_mag_fact, dpy_depth,
  221.         frames, fn, channels, dpy_channels,
  222.         *hist, *histp;    /* histogram buffer & pointer    */
  223.     byte    *data, *scan_data,    /* original data & scan buffers    */
  224.         *cnvt,
  225.         *img_buf, *icon_buf;    /* map buffers for image & icon    */
  226.     bool    sub_img, sub_img_enh,    /* sub window and enhance    */
  227.         active, rw_cmap,    /* writable colormap    */
  228.         color_dpy,        /* False if black/white    */
  229.         dither_img, update,
  230.         logscale, setscale,    /* use unique / own max histogram count */
  231.         load_all, save_all;
  232.     int    in_type, mid_type, o_type, in_color, color_form,
  233.         in_form, o_form, pxl_in, pxl_out;
  234.     FILE    *IN_FP, *OUT_FP;
  235.     Mregister    mmm, *marray;
  236.     StdInterface    *errors, *header_handle, *std_swif,
  237. /* pipe & RTP */    *close, *eof, *open, *read, *seek, *write;
  238.     TableInterface    (*table_if)(), **table, tables;
  239.     superimpose_elems    **superimpose;
  240.     PanelParts    *parts;
  241.     short    draws, texts, stack_num;/* parts in part stack    */
  242.     void    (*map_scanline)(), (*MAG_scanline)();
  243.     bool    binary_img,
  244.         mono_img,
  245.         mono_color,
  246.         sep_colors,
  247.         pixmap_failed;    /* as update_header flag in U_IMAGE    */
  248.     int    entries,    /* number of colors or gray levels    */
  249.         ncmap, cmaplen;    /* in regular length (not 2 ** cmaplen)    */
  250.     cmap_t    **in_cmap;
  251.     int    lvls, lvls_squared, visual_class;
  252.     Visual    *dpy_visual;
  253. #if    defined    EXTENDED_COLOR | defined C_TUNER
  254.     Window    pix_info_window;
  255.     Pixmap    pixmap, icn_pixmap, mag_pixmap, refresh_pixmap;
  256.     float    gamma, dpy_gamma;
  257.     char    *title;
  258.     int    cmlen,    /* color_map-length in Comment    */
  259.         *modN, *divN, **dm16;
  260.     unsigned int    *pixel_table;
  261. #endif
  262.     } Image;
  263.  
  264.  
  265. #if    defined    C_TUNER | defined RLE_IMAGE
  266.  
  267. #include "getx11.h"
  268.  
  269. typedef struct    {
  270.     char    *name, *history, *desc;
  271.     Colormap colormap;
  272.     Display    *dpy;
  273.     GC    gc, icn_gc;
  274.     Window    frame, window, icn_window;
  275.     XEvent    *event;
  276.     int    x, y, w, h,    /* origin, width & height of image    */
  277.         icn_w, icn_h, font_w, font_h, ascent;
  278.     XImage    *image, *icn_image;
  279.     int    curve, linearlow, linearup, bgrd, fgrd,
  280.         scale, tmp_offset,
  281.         mark_x, mark_y, resize_w, resize_h,
  282.         sub_img_x, sub_img_y, sub_img_w, sub_img_h,
  283.         mag_fact, mag_mode,/* current magnification factor    */
  284.         mag_x, mag_y, mag_w, mag_h,
  285.         save_mag_x, save_mag_y, save_mag_w, save_mag_h,
  286.         save_mag_fact, dpy_depth,
  287.         img_num, RGB,    /* operated channel    */
  288.         img_channels,    /* # of color channels in file    */
  289.         dpy_channels,    /* # of channels can display    */
  290.         *hist, *histp;
  291.     byte    *data, *scan_data,    /* [h][w][chnl] */
  292.         *cnvt, *img_buf, *icon_buf;
  293.     bool    sub_img, sub_img_enh,
  294.         active, rw_cmap,
  295.         color_dpy, dither_img,    /* dither it? (-a) */
  296.         update, logscale, setscale,
  297.         load_all, save_all;
  298.     int    in_type, mid_type, o_type, in_color, color_form,
  299.         in_form, o_form, pxl_in, pxl_out;
  300.     FILE    *IN_FP, *OUT_FP;
  301.     Mregister    mmm, *marray;
  302.     StdInterface    *errors, *header_handle, *std_swif,
  303.             *close, *eof, *open, *read, *seek, *write;
  304.     TableInterface    (*table_if)(), **table, tables;
  305.     VType    **superimpose;    /* all SIs can be stored in image headers */
  306.     PanelParts    *parts;
  307.     short    draws, texts, stack_num;
  308.     VOID_FUNCTION    *map_scanline,    /* for scanline routines using    */
  309.             *MAG_scanline;
  310.     bool    binary_img,    /* make it 2 colors (-W)    */
  311.         mono_img,    /* make it grey scale (-w)    */
  312.         mono_color,    /* a one channel color image (mcut)    */
  313.         sep_colors,    /* is the visual True or DirectColor?    */
  314.         pixmap_failed;
  315.     int    entries,    /* number of colors or gray levels    */
  316.         ncmap,    /* rle_hdr.ncmap */
  317.         cmaplen;
  318.     rle_pixel**    in_cmap;/* LAST item in the Image structure */
  319.  
  320.     int    lvls, lvls_squared,
  321.         visual_class;
  322.     Visual    *dpy_visual;
  323.     Window    pix_info_window;
  324.     Pixmap    pixmap, icn_pixmap, mag_pixmap, refresh_pixmap;
  325.     float    gamma, dpy_gamma;
  326.     char    *title;
  327.  
  328.     int    cmlen,    /* Comment `color_map_length` in file    */
  329.         *modN, *divN;    /* dither arrays, all of them    */
  330.     array16 *dm16;
  331.     Pixel    *pixel_table;
  332.     } image_information;
  333.  
  334. typedef    union    {
  335.     Image    b_w;
  336.     image_information    color;
  337.     } *IMAGESP;
  338.  
  339. #endif    C_TUNER
  340.  
  341.  
  342. typedef    struct    {
  343.     Image    *his;
  344.     int    *hist, *histp, grids, neg, scale;/* is in logarithm */
  345.     bool    change, map;
  346.     void    *lkt;
  347.     } HistoInfo;
  348.  
  349. /*    End of Type Define    */
  350.  
  351.     /*    Exports    */
  352. extern    Image        *CreateImage(/* *ip, name, attr, w, h, i_w, mask, bf */);
  353. extern    Panel        *CreatePanel(/* x0, y0, w, h, name, attr, mask */);
  354. extern    Button        *CreateButton(/* *panel, x, y, n, name, blist, bc, pc */);
  355. extern    PressButton    *CreatePressButton(/* *panel, x, y, name, prscolor */);
  356. extern    PopMenu        *CreatePopMenu(/* *panel, attr, name, menu, num */);
  357. extern    Slider        *CreateSlider();
  358. extern    ScrollBar    *CreateScrollBar(), **SB_Stack;
  359. extern    char        *ReadButton();
  360. extern    void    EraseSlider(), DestroyImage(), LoadIcon(),
  361.         PanelSet(/* VType *item, int SettingCode, ... */);
  362. extern    int    CreateWindow(/* *wp, attr, cursor, mask, fixedframe, flag */),
  363.         DrawSlider(), DrawButton(), DrawPressButton(), PopingMenu(),
  364.         ReadSlider(/* *sp, bar_number */),
  365.         SliderInfo(), SetSBarPos(), SetSBarRpos(),
  366.         WhichImage(/* win, *imgp, total_images */),
  367.         TrackSubWin(/* *img, hist_info, X0, Y0 */),
  368.         Draws(/* *img, x_pos, draw_only, shape */),
  369.         DrawVMark(/* *img, x_pos, clean */);
  370. extern    bool    ButtonPressed(), OnSliderBar(), OnButton();
  371. extern    Font    SetFontGetSize();    /* =u_long defined in X.h L42 */
  372.     /* detect the available color map entries */
  373. extern    PColor    GetVctEntry(/* dpy, scr, cmap, set_grays */),
  374.         GetCloseColor(/* dpy, cmap, entries, r, g, b */);
  375. extern    PColor    Black, White, Visible, darkGray, lightGray, Gray,
  376.         Red, Green, Blue, Yellow, black1, white1, gray1, HBGround;
  377.  
  378.     /*    import */
  379. extern    bool    debug, tuner_flag, OsameI, multi_hd;
  380. extern    char    *strcpy(), *DrawShape[];
  381.  
  382. #ifndef    MaxColors
  383. #define    MaxColors    256
  384. #endif
  385.  
  386. #define    HistoSize    256    /* histogram bins */
  387. #define    BGround        7    /* pseudo panel background color */
  388. #define    BFRAME        1    /* histogram image frame thickness */
  389.  
  390. #define    StdIconWidth    128
  391. #define    RailWidth    4    /* slider rail width */
  392. #define    HandleWidth    10    /* sliding bar or scrollbar size */
  393. #define    HandleHeight    20
  394. #define    TextVMargin    15    /* vertical and */
  395. #define    TextLMargin    8    /* horizontal margin */
  396. #define    ButtonHeight    20
  397. #define    IIMargin    4    /* Image Infomation Margin */
  398.  
  399. #define    DoAll        DoRed | DoGreen | DoBlue
  400. #define    ButtonAction    (ButtonPressMask | ButtonReleaseMask)
  401.  
  402. #define    DrawsArc    1
  403. #define    DrawsLine    2
  404. #define    DrawsRect    3
  405. #define    DrawArc(a,b,c)        Draws(a,b,c,DrawsArc)
  406. #define    DrawCrop(a,b,c)        Draws(a,b,c,DrawsRect)
  407. #define    DrawLine(a,b,c)        Draws(a,b,c,DrawsLine)
  408.  
  409. #ifndef    CropButton
  410. #define    CropButton    Button3Mask
  411. #endif
  412.  
  413. #endif    PANEL_H
  414.